﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

       

        private void button1_Click(object sender, EventArgs e)
        {
            getLokal();
            tbip.Text = Ip();
        }

        private void getLokal()
    {
        tbname.Text = Dns.GetHostName();
    }
        private void lokalIp() 
        {
            
        }
        private string Ip() 
        { string ip = ("");
           WebRequest wr = WebRequest.Create("http://checkip.dyndns.org/ ");
           WebResponse wr2 = wr.GetResponse();
          StreamReader sr = new StreamReader(wr2.GetResponseStream());
          
      ip= sr.ReadToEnd();
           
          int adress =ip.IndexOf ("s: ")+3;
          int body = ip.IndexOf("</body>");
            ip.Substring(adress,body-adress);
           // return  ;
            
       
        }
    }
}
